package com.bojiu.lawsearch.lawsearch.controller;

import com.bojiu.lawsearch.lawsearch.model.Profession;
import com.bojiu.lawsearch.lawsearch.model.Unit;
import com.bojiu.lawsearch.lawsearch.model.UnitDetail;
import com.bojiu.lawsearch.lawsearch.service.ProfessionService;
import com.bojiu.lawsearch.lawsearch.util.JsonResult;
import com.bojiu.lawsearch.lawsearch.util.ResultCode;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author: afdiao
 * @Date：2020/3/24 22:05
 * @Description:前台获取标签等信息
 */
@RestController
@RequestMapping("webkey")
@Slf4j
public class WebKeyController {

    @Autowired
    ProfessionService professionService;

    @GetMapping("getProfession")
    public JsonResult getProfession() {
        List<Profession> allProfession = professionService.getAllProfession();
        return new JsonResult(ResultCode.SUCCESS, allProfession);
    }

    @GetMapping("unit")
    public JsonResult getAllUnit() {
        List<Unit> allUnit = professionService.getAllUnit();
        return new JsonResult(ResultCode.SUCCESS, allUnit);
    }

    @GetMapping("unitDetail/{unit}")
    public JsonResult getAllUnitDetail(@PathVariable("unit") int unit) {
        List<UnitDetail> allUnitdetailById = professionService.getAllUnitdetailById(unit);
        return new JsonResult(ResultCode.SUCCESS, allUnitdetailById);
    }
}
